<template>
  <div>
    <Modal v-model="show" :title="title" :mask-closable="false" :footer-hide=true width="600px" :closable="false">
      <Form :model="rowData">
        <FormItem :label="$t('dispose_spec')">
          <Input clearable :placeholder="$t('dispose_spec')" v-model="rowData.disposeRemark" ></Input>
        </FormItem>
        <FormItem>
          <div style="float: right;">
            <Button style="margin-right: 10px" type="primary"  @click="save" >{{$t('save')}}</Button>
            <Button @click="close">{{$t('cancel')}}</Button>
          </div>
        </FormItem>
      </Form>
    </Modal>
  </div>
</template>
<script>
import {apiResult} from "@/libs/util";
import DeviceAlarm from "@/api/DeviceAlarm";

export default {
  name: "AlarmManageDispose",
  data(){
    return{
      api: new DeviceAlarm(),
      title: this.$t('p_alarmManage_dispose'),
      show: false,
      rowData: {
        id: null,
        disposeRemark: null,
      },
      callback: null
    }
  },
  methods:{
    openDialog(row,callback){

      this.rowData.id = row.id;
      this.rowData.disposeRemark = row.disposeRemark;
      this.callback = callback;
      this.show = true;
    },
    save(){
      //this.row.disposeRemark = 1;
      const msg = this.$Message.loading({content: this.$t('wait_dispose_message'),duration: 10});
      this.api.dispose(JSON.stringify(this.rowData)).then(res => {
        setTimeout(msg, 100); //关闭正加载条
        apiResult(res.data,true,result=>{
          this.show = false;

          if (!!this.callback)
            this.callback();
        });
      })

    },
    close(){
      this.show =false;
    }
  }
}
</script>
<style>

</style>
